package harlequin;

import java.sql.*;

public class Connector {
    private static String url="jdbc:mysql://localhost:3306/"; 
    private static String dbName="harlequin";
    private static String driver="com.mysql.jdbc.Driver";
    private static String userName="root";
    private static String password="root";
    private static Connection conn;
    
    public static boolean connect()
    {
        try {
            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(url+dbName,userName,password);
            System.out.println("Connected to the database");
        }catch(Exception e){
            return false;
        }
        return true;
    }
  
    public static Connection getConnector()
    {
        return conn;
    }
    public static boolean isConnected(){
        return (conn == null ? false : true);
    }
    public static boolean disconnect() {
        try{
            conn.close();
        }catch(Exception e){
            return false;
        }
        return true;
    }
}
